package com.dpad.telematicsclientapp.utils

import android.content.Intent
import com.alibaba.android.arouter.launcher.ARouter
import com.dpad.telematicsclientapp.netlibrary.Contances
import com.dpad.telematicsclientapp.netlibrary.MainApplicaton
import com.dpad.telematicsclientapp.netlibrary.base.basecopy.AppManager
import com.dpad.telematicsclientapp.util.utils.Constant


/*
    顶级函数，判断是否登录
 */
fun isLogined(): Boolean {
    return MainApplicaton.sIsLogin
}

/*
    如果已经登录，进行传入的方法处理
    如果没有登录，进入登录界面
 */
fun afterLogin(method: () -> Unit) {
    if (isLogined()) {
        method()
    } else {
//        val intent = Intent(AppManager.getInstance().currentActivity, KtLoginActivity::class.java)
//        intent.putExtra(Constant.LOGIN_KEY, false)
//        AppManager.getInstance().currentActivity.startActivity(intent)

        ARouter.getInstance()
                .build(Contances.URL_ACTIVITY_LOGIN, Contances.GROUP_LOGIN)
                .withBoolean(Constant.LOGIN_KEY, false)
                .navigation(AppManager.getInstance().currentActivity)


    }
}
